Chris Pollett >
Old Classes
> |
HW#2 --- last modified January 01 1970 00:00:00..Due date: Mar 1
Files to be submitted: Purpose: To write a simple servlet. To use some of the classes in java.util we've discussed. Specification: For this homework you will write an HTTPServlet to add email addresses to an existing flat file of student data. Initially, when no form data has yet been sent to your servlet, your servlet writes out the HTML to display a page that looks like: After this it reads in the file CS100.txt, which, to keep things simple, lives in the same directory as the servlet. (Do not hard code where the servlet is! Use the HttpServlet method getServletContext().getRealPath(""); to figure it out dynamically). You should use one of the storage data structures we learned about in java.util.* to store the data from CS100.txt. For example, you could use an ArrayList. CS100.txt has rows which consists of items enclosed quotes separated by tabs (this makes it easy to read into Excel). The first row contains meta data about the file. It might look like: "Name" "StudentID" "EMAIL" "HW1" "HW2" "HW3" "HW4" "MID" "FINAL" Note: The actual format of first row may contain more items and the items in different positions, but it is guaranteed to have "StudentID" and "EMAIL". This meta row specifies which column in the rest of the rows has what data. A typical row in the rest of the file might look like: "Chris Pollett" "000-00-0000" "" "5" "6" "8" "9" "20" "40" Your servlet should find the row which corresponds to the submitted ID. It then should update the value of the EMAIL column in this row, save the updated data back out to the file CS100.txt, and output a page that looks like:
If the studentID did not correspond to a row in the file your program should output a page:
Point Breakdown
|